Skip to content

[MWAR-446] Add compressLibs option to store dependency JARs in STORED mode - #640

Open
elharo wants to merge 2 commits into
apache:masterfrom
elharo:MWAR-446-compress-libs
Open

[MWAR-446] Add compressLibs option to store dependency JARs in STORED mode#640
elharo wants to merge 2 commits into
apache:masterfrom
elharo:MWAR-446-compress-libs

Conversation

@elharo

@elharo elharo commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Fixes #526

Add a new compressLibs parameter (default: true) to the maven-war-plugin. When set to false, dependency library JARs in WEB-INF/lib/ are stored in the WAR archive using STORED mode (no compression) instead of DEFLATED mode.

Why: JAR files are already compressed internally. Re-compressing them when adding to a WAR provides negligible size reduction but adds CPU overhead during both WAR creation and servlet container startup (the JARs must be decompressed before they can be loaded). Storing them in STORED mode eliminates this redundant compression.

Implementation: Creates an UncompressedLibsWarArchiver subclass of WarArchiver that overrides zipFile() to temporarily disable compression for entries under WEB-INF/lib/, while all other entries (classes, resources, web.xml, etc.) continue to be compressed normally.

Usage:

<configuration>
  <compressLibs>false</compressLibs>
</configuration>

Changes:

  • AbstractWarMojo.java: Added compressLibs parameter with getter
  • WarMojo.java: Added UncompressedLibsWarArchiver inner class; getWarArchiver() returns it when compressLibs=false
  • Integration test MWAR-446 verifying JARs are STORED and other entries are DEFLATED

private boolean recompressZippedFiles;

/**
* Whether dependency libraries (i.e. JAR files in {@code WEB-INF/lib/}) should be compressed (DEFLATED) when

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove i.e.,

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new compressLibs configuration knob to the Maven WAR Plugin to optionally store WEB-INF/lib dependency JARs using STORED (no compression) to avoid redundant compression overhead, along with an integration test to validate mixed STORED/DEFLATED output.

Changes:

  • Introduce compressLibs parameter (default true) to control compression of dependency JARs under WEB-INF/lib/.
  • Add a WarArchiver subclass that conditionally disables compression for library entries while keeping other WAR entries compressed.
  • Add IT MWAR-446 verifying WEB-INF/lib/*.jar are STORED and a normal resource is DEFLATED.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/main/java/org/apache/maven/plugins/war/WarMojo.java Chooses a custom archiver when compressLibs=false and overrides zip behavior for WEB-INF/lib/.
src/main/java/org/apache/maven/plugins/war/AbstractWarMojo.java Adds the compressLibs parameter and accessor.
src/it/MWAR-446/pom.xml New integration test project enabling compressLibs=false.
src/it/MWAR-446/verify.groovy Verifies STORED vs DEFLATED methods inside the produced WAR.
src/it/MWAR-446/src/main/webapp/index.html Simple resource to assert DEFLATED behavior remains for non-lib entries.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 389 to +395
public WarArchiver getWarArchiver() {
try {
return (WarArchiver) getArchiverManager().getArchiver("war");
if (isCompressLibs()) {
return (WarArchiver) getArchiverManager().getArchiver("war");
} else {
return new UncompressedLibsWarArchiver();
}
String symlinkDestination,
boolean addInParallel)
throws IOException, ArchiverException {
if (vPath.startsWith("WEB-INF/lib/") && !vPath.endsWith("/")) {
@elharo
elharo force-pushed the MWAR-446-compress-libs branch from a1579bc to 0e9945b Compare July 26, 2026 19:27
… mode

Add a new compressLibs parameter (default: true) that allows storing
dependency library JARs in WEB-INF/lib/ using STORED compression mode
instead of DEFLATED. This improves servlet container startup time since
already-compressed JARs don't need to be decompressed during WAR
extraction, with negligible impact on overall WAR file size.

Implements: apache#526
@elharo
elharo force-pushed the MWAR-446-compress-libs branch from 0e9945b to 4d38e06 Compare July 26, 2026 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[MWAR-446] Add an option to put libs in STORED mode (instead of DEFLATED)

2 participants